package com.example.generic;

public class PairTest02 {
    public static void main(String[] args) {

    }
}

class ArrayAlg {
//                   类型变量的限定
    public static <T extends Comparable> Pair<T> minmax(T[] a){
        if(a == null || a.length == 0){
            return null;
        }
        T min = a[0];
        T max = a[0];
        for(int i = 1; i < a.length; i++){
            if(min.compareTo(a[i]) > 0) min = a[i];
            if(max.compareTo(a[i]) < 0) max = a[i];
        }
        return new Pair<>(min, max);
    }
}

class Pair<T extends Comparable> {
    private Object first;
    private Object second;

    public Object getFirst() {
        return first;
    }

    public void setFirst(Object first) {
        this.first = first;
    }

    public Object getSecond() {
        return second;
    }

    public void setSecond(Object second) {
        this.second = second;
    }

    public Pair(Object first, Object second) {
        this.first = first;
        this.second = second;
    }
}